import { useState } from 'react'
import { Button, Form, Input } from 'antd'
import styles from './index.module.less' // 引用module.css样式
import api from '@/api'
import { message } from '@/utils/AntdGlobal'
export default function LoginFC() {
  const [loading, setLoading] = useState(false)
  const onFinish = async (values: any) => {

    // 全局已定义
    // const a = window.getUser()
    window.baidu = 123456456
    window.app = '123'
    // globalFunction('2') // 报错，没搞懂
    console.log(window.baidu, window.app)

    api.login(values).then(res => {
      message.success('Success!');
      console.log('res', res)
    })
  }
  return (
    <div className={styles.login}>
      <div className={styles.loginWrapper}>
        <div className={styles.title}>系统登录</div>
        <Form name='basic' initialValues={{ remember: true }} onFinish={onFinish} autoComplete='off'>
          <Form.Item name='userName' rules={[{ required: true, message: 'Please input your username!' }]}>
            <Input />
          </Form.Item>

          <Form.Item name='userPwd' rules={[{ required: true, message: 'Please input your password!' }]}>
            <Input.Password />
          </Form.Item>

          <Form.Item>
            <Button type='primary' block htmlType='submit' loading={loading}>
              登录
            </Button>
          </Form.Item>
        </Form>
      </div>
    </div>
  )
}
